package com.qianfeng.yime;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;

/**
 * Created by IDEA
 * User : SL
 * on  2015/3/9.
 * 20:46
 */
public class SplashActivity extends Activity implements Runnable{
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        new Thread(this).start();
    }

    @Override
    public void run() {
        try {
            Thread.sleep(2000);

            //通过 SharedPreference 进行是否显示过教程的判断
            SharedPreferences preferences = getSharedPreferences(Constants.SP_APP_DATA, MODE_PRIVATE);

            //是否显示过教程
            boolean b = preferences.getBoolean(Constants.SP_KEY_TUTORIAL_SHOWN, false);

            if (b){
                //显示过教程，直接加载主页面
                startActivity(new Intent(this, MainActivity.class));
            }else {
                //没有显示过教程，显示教程界面
                startActivity(new Intent(this, TutorialActivity.class));
            }
            finish();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}